-- TimeUI
-- 计时组件
TimeUI = class()

function TimeUI:init()
    self.t = os.time()
    self.timeTable = os.date("*t", t)
    self.weekday =self.timeTable.wday - 1
    self.yearday = self.timeTable.yday - 1
end

-- 今天是今年第几周
function TimeUI:WeekInYear()
    self.baseday = 7 - (self.yearday + 1 - (self.weekday + 1)) % 7
    if self.baseday == 7 then
        self.baseday = 0
    end
    local yearweek = math.floor((self.baseday + self.yearday) / 7)
    return yearweek
end

-- 今天星期几
function TimeUI:WeekDay()
    return os.date("%A",self.t)
end

-- 年月日
function TimeUI:Nowdate()
    return os.date("%x",self.t)
end

-- 今年是不是闰年（是返回true，不是返回false）
function TimeUI:IsThisYearLeap()
    if self.timeTable.year % 4 == 0 then
        return true
    else return false
    end
    return
end

-- “year”是不是闰年（是返回true，不是返回false）
function TimeUI:IsLeap(year)
    if year % 4 == 0 then
        return true
    else return false
    end
    return
end

-- 大月，小月，平月检测
function TimeUI:SolorMonth()
    solor = nil
    if self.timeTable.month == 1 or self.timeTable.month == 3 or self.timeTable.month == 5 or self.timeTable.month == 7 or self.timeTable.month == 8 or self.timeTable.month == 10  or self.timeTable.month == 12 then
        solor = "大月"
    elseif self.timeTable.month == 2 then
        solor = "平月"
    else
        solor = "小月"
    end
    return solor
end

--是否这一天
function TimeUI:IsInDay(month, day)
    if self.timeTable.month == month and self.timeTable.day == day then
        return true
    else return false
    end
end



